<template>
	<div class="evens">
		<div style="height:18px;"></div>
		<InfoList :data="data" :number="pageSize" :keywords="keywords" 
		v-on:Upnumber="upSize($event)" v-on:refresh="refresh()" v-on:setAsc="setAsc()" v-on:setDesc="setDesc()"  :topic='true'></InfoList>
		<div class="pagination">
		    <el-pagination
		      @size-change="handleSizeChange"
		      @current-change="handleCurrentChange"
		      :current-page="1"
		      :page-sizes="[100, 80, 50, 30]"
		      :page-size="pageSize"
		      layout="total, sizes, prev, pager, next, jumper"
		      :total="total">
		    </el-pagination>
		</div>
	</div>
</template>
<script >
import ArgList from 'components/Home/ArgList'
import InfoList from 'components/Home/InfoList'
	export default {
		name:'evens',
		components:{ArgList,InfoList},
		data(){
			return{
				pageNum:1,
				pageSize:50,
				data:[],
				total:0,
				keywords:[],
				sortType:''
			}
		},
		computed:{
			thisId:function(){
				return this.$store.state.Topic.topicId||localStorage.topicId
			}
		},
		mounted(){
			this.getMore()
		},
		methods:{
			// 升序
			setAsc(){
				this.sortType = 'asc'
				this.getMore()
			},
			setDesc(){
				this.sortType = 'desc'
				this.getMore()
			},
			refresh(){
				this.getMore()
			},
			async	getMore(){
					this.$store.commit('LoadingTrue');
					let res = await this.$http.post('/vrv-monitor-platform-web/data/query',{
							topicId:this.thisId,
							currentPage:this.pageNum,
							limit:this.pageSize,
							sortType:this.sortType,
							sortField:'poTime'
					})
					if(res.body.success == true){
						this.total = res.body.totals>3000?3000:res.body.totals
						this.data = res.body.data
						this.keywords = res.body.keywords
						this.data.forEach((value,index)=>{
							this.$set(value,'readText', 0 )
							this.$set(value,'checked', false )
							if (localStorage.read) {
										let _readArr = localStorage.read
										let readArr = JSON.parse(_readArr);
										if(readArr.indexOf(value.id)!=-1){
											this.$set(value,'isread', true )
										}else{
											this.$set(value,'isread', false )
										}
							}else{
								this.$set(value,'isread', false )
							}

							if(value.collected==false||value.collected=='false'){
								this.$set(value,'enshrine', false )
							}else{
								this.$set(value,'enshrine', true )
							}

							let imgurl = value.domain
							this.$http.get(`static/${imgurl}.png`).then(res=>{
								this.$set(value,'urlimg', `url(static/${imgurl}.png)` )
							}).catch(err=>{
								this.$set(value,'urlimg',"url('static/defult.png')")
							})
						})
					}else{
						this.$message.error(res.body.message)
					}
					this.$store.commit('Loadingfalse');
		    },
			handleSizeChange(val){
				this.pageSize = val
				this.getMore()
			},
			handleCurrentChange(val){
			this.pageNum = val
			this.getMore()
			},
			upSize(e){
				this.pageSize = e
				this.getMore()
			},
		}
	}
</script>
<style scoped>
	.pagination{
		text-align: right;
		padding: 0.93rem 0.93rem;
	}
</style>